package cn.com.simple.learning.webflux.route;

import cn.com.simple.learning.webflux.handler.UserHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.ServerResponse;

import static org.springframework.web.reactive.function.server.RouterFunctions.route;

/**
 * @author Jianxing.Jia
 * @date 2022/6/7
 * @description 描述信息
 */
@Configuration
public class RouteConfig {

    @Bean
    public RouterFunction<ServerResponse> userRoute(UserHandler userHandler) {

        return route()
                .GET("/hello/", userHandler::hello)
                .GET("/user/", userHandler::getUsers)
                .GET("user/{id}", userHandler::getUserById)
                .GET("user/sync/{id}", userHandler::getUserByIdSync)
                .POST("/user/", userHandler::save)
                .DELETE("/user/{id}", userHandler::deleteUserById).build();
    }

}
